<!DOCTYPE html>
<html lang="zh-CN">

<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>对象浅拷贝</title>
</head>

<body>

</body>
<script>
    "use strict"; {
        // 通过for in
        let yc = {
            name: "yc",
            age: 19
        };
        let obj = {};
        for (let key in yc) {
            obj[key] = yc[key];
        };
        console.table(obj);
        console.table(yc);
    }; {
        // 通过 ...展开语法
        let yc = {
            name: "haha",
            age: 10,
            say: "好的"
        };
        let obj1 = { ...yc };
    }; {
        // 通过assign
        let yc = {
            name: "lai",
            age: 190
        };
        let obj = Object.assign({}, yc);
        console.log(`assign`, JSON.stringify(obj, null, 2));
    };
</script>

</html>